//
//  UPStocksAPIManager.m
//  Uang Pasti
//
//  Created by 李永彬 on 2025/8/16.
//

#import "UPStocksAPIManager.h"

@implementation UPStocksAPIManager

+ (void)fetchEnvironmentWithCompletion:(void(^)(UPYinDaoModel *yinDaoModel, NSString * _Nullable msg))completion {
    NSDictionary *params = @{
        @"friendant": @"0",
        @"amphcy": @"0",
        @"institutioness": [[AppConfig sharedInstance] appLanguageCode]
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/primdom"
                              domainType: UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded
                                callback:^(UPResponse *response) {
        
        if (response.lotfication == 0) {
            UPYinDaoModel *model = [UPYinDaoModel mj_objectWithKeyValues:response.lapidant];
            [AppConfig sharedInstance].countryId = model.othersary;
            if (model.othersary != nil) {
                [UPUserDefaults setString:model.othersary forKey: environmentCountryKey];
            }
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchLoginVCodeWithPhoneNum: (NSString *) phoneNum completion:(void(^)(UPLoginVCodeModel * _Nullable vCodeModel, NSString * _Nullable msg))completion {
    NSDictionary *params = @{
        @"third": phoneNum,
        @"imagineaire": confusionString(),
        @"coupleably": confusionString()
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/third"
                              domainType: UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded
                                callback:^(UPResponse *response) {
        
        if (response.lotfication == 0) {
            UPLoginVCodeModel *model = [UPLoginVCodeModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchLoginWithPhoneNum: (NSString *) phoneNum code: (NSString *)code completion:(void(^)(UPLoginModel * _Nullable loginModel, NSString * _Nullable msg))completion {
    NSDictionary *params = @{
        @"violencear": phoneNum,
        @"emuling": code,
        @"flamform": confusionString(),
        @"mne": confusionString()
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/coupleably"
                              domainType: UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded
                                callback:^(UPResponse *response) {
        
        if (response.lotfication == 0) {
            UPLoginModel *model = [UPLoginModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
            
            [UPUserDefaults setString:phoneNum forKey:loginPhoneNumberKey];
            if (model.aroundan != nil) {
                [UPUserDefaults setString:model.aroundan forKey: loginSessionIdKey];
            }
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchLoginOutWithCompletion:(void(^)(BOOL status, NSString * _Nullable msg))completion {
    NSDictionary *params = @{
        @"ap": confusionString(),
        @"ideaetic": confusionString()
    };
    
    [UPNetworkManager.sharedManager GET:@"/openry/lotfication"
                             domainType:UPDomainTypeDefault
                                 params:params
                            contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            completion(YES, response.enneasome);
            [[NSNotificationCenter defaultCenter] postNotificationName:kLogOutOrExpiredNotificationKey object:nil];
        } else {
            completion(NO, response.enneasome);
        }
    }];
}

+ (void)fetchAccountCancelWithCompletion:(void(^)(BOOL status, NSString * _Nullable msg))completion {
    NSDictionary *params = @{
        @"pans": confusionString()
    };
    
    [UPNetworkManager.sharedManager GET:@"/openry/censular"
                             domainType:UPDomainTypeDefault
                                 params:params
                            contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            completion(YES, response.enneasome);
            [[NSNotificationCenter defaultCenter] postNotificationName:kLogOutOrExpiredNotificationKey object:nil];
        } else {
            completion(NO, response.enneasome);
        }
    }];
}

+ (void)fetchHomeInfomationWithCompletion:(void(^)(Lapidant *model, NSString * msg))completion {
    NSDictionary *params = @{
        @"psychr": confusionString()
    };
    
    [UPNetworkManager.sharedManager GET:@"/openry/enneasome"
                             domainType:UPDomainTypeDefault
                                 params:params
                            contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            Lapidant *model = [Lapidant mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchApplyWithProductId: (NSString *)productId completion:(void(^)(ProductApplyModel * _Nullable model, NSString * _Nullable msg))completion {
    NSDictionary *params = @{
        @"collegefold": productId,
        @"outeur": confusionString(),
        @"peculieous": @"1001",
        @"liev": @"1000",
        @"littleice": @"1000"
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/flamform"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            ProductApplyModel *model = [ProductApplyModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchLoanHistoryListWithButtonType: (LoanHistoryListType)listType   completion:(void(^)(HistoryLapidantModel * _Nullable model, NSString * _Nullable msg))completion {
    NSDictionary *params = @{
        @"andresque": [NSString stringWithFormat:@"%lu", (unsigned long)listType],
        @"docuel": @"1",
        @"serpitious": @"50"
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/leaderible"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            HistoryLapidantModel *model = [HistoryLapidantModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}


+ (void)fetchMyLoanDetailWithProductId: (NSString *)productId  completion:(void(^)(LoanDetailModel * _Nullable model, NSString * _Nullable msg))completion {
    NSDictionary *params = @{
        @"collegefold": productId,
        @"plagen": confusionString()
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/mne"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            LoanDetailModel *model = [LoanDetailModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchAuthenticationWithProductId: (NSString *)productId  completion:(void(^)(IdentityVerificationModel *model, NSString * msg))completion {
    NSDictionary *params = @{
        @"collegefold": productId,
        @"thymation": confusionString()
    };
    
    [UPNetworkManager.sharedManager GET:@"/openry/daughter"
                             domainType:UPDomainTypeDefault
                                 params:params
                            contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            IdentityVerificationModel *model = [IdentityVerificationModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchAddressWithCompletion:(void(^)(ADRLapidantModel *model, NSString * msg))completion {
    NSDictionary *params = @{
        @"molance": confusionString(),
        @"gymnile": confusionString()
    };
    
    [UPNetworkManager.sharedManager GET:@"/openry/choiceard"
                             domainType:UPDomainTypeDefault
                                 params:params
                            contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            ADRLapidantModel *model = [ADRLapidantModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void) fetchUploadWithImageData: (NSData *)data imageType: (AuthImagePickerType)imageType completion:(void(^)(AuthLapidant *model, NSString * msg))completion {
    NSString *tergmost = @"10";
    switch (imageType) {
        case AuthImagePickerTypePRC:
            tergmost = @"11";
            break;
        case AuthImagePickerTypeFace:
            tergmost = @"10";
            break;
            
        default:
            break;
    }
    NSDictionary *parameters = @{};
    if ([AppConfig sharedInstance].appCountryEnv == AppCountryEnvIndonesia) {
        parameters = @{
            @"tergmost": tergmost,
            @"sanive": @"2",
            @"schisious": @"",
            @"bovitor": @"1",
            @"theri": confusionString()
        };
    } else {
        parameters = @{
            @"tergmost": tergmost,
            @"sanive": @"2",
            @"schisious": @""
        };
    }
    
    [UPNetworkManager.sharedManager upload:@"/openry/nomible"
                                domainType:UPDomainTypeDefault
                                    params:parameters
                                  fileData:data
                                      name:@"importantid"
                                  fileName:@"test.jpg"
                                  mimeType:@"image/jpeg"
                                  progress:^(NSProgress *progress) {
        
    } callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            AuthLapidant *model = [AuthLapidant mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchSaveIdentifyInfoWithName:(NSString *)name
                                idNum:(NSString *)idNum
                             birthday:(NSString *)birthday
                            productId:(NSString *)productId
                           productNum:(NSString *)productNum
                           completion:(void(^)(BOOL success, NSString * msg))completion {
    
    NSString *path = @"/openry/septuagentic";
    NSDictionary *parameters = @{};
    if ([AppConfig sharedInstance].appCountryEnv == AppCountryEnvIndonesia) {
        parameters = @{
            @"plorfication": confusionString(),
            @"ficiie": confusionString(),
            @"movieion": birthday ?: @"",
            @"assumeization": idNum,
            @"quindecimlocalety": name,
            @"consumeratic": [UPUserDefaults stringForKey:loginPhoneNumberKey],
            @"freeid": productNum,
            @"collegefold": productId
        };
        path = @"/openry/septuagentic";
    } else {
        parameters = @{
            @"movieion": birthday,
            @"assumeization": idNum,
            @"quindecimlocalety": name,
            @"tergmost": @"11",
            @"ag": confusionString()
        };
        path = @"/openry/societyling";
    }
    
    [UPNetworkManager.sharedManager POST:path
                              domainType:UPDomainTypeDefault
                                  params:parameters
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            completion(YES, response.enneasome);
        } else {
            completion(NO, response.enneasome);
        }
    }];
}

+ (void)fetchFollowUpMyProduct: (OmniosityModel *)omniosity
                    completion:(void(^)(FollowLapidant *lapidant, NSString * msg))completion {
    
    NSString *productNum = [NSString stringWithFormat:@"%@", omniosity.viciacity];
    NSDictionary *params = @{
        @"freeid": productNum,
        @"testity": omniosity.testity,
        @"pando": omniosity.pando,
        @"athroidbit": omniosity.athroidbit,
        @"rapacesque": confusionString(),
        @"collegesive": confusionString()
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/tergmost"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            FollowLapidant *model = [FollowLapidant mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchPersonalInfoWithProductId: (NSString *)productId
                            completion:(void(^)(PersonalLapidantModel *lapidantModel, NSString * msg))completion {
    
    NSDictionary *params = @{
        @"collegefold": productId
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/hum"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            PersonalLapidantModel *model = [PersonalLapidantModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchSavePersonalInfoWithProductId: (NSString *)productId
                             lapidantModel: (PersonalLapidantModel *)lapidantModel
                                completion:(void(^)(BOOL successs, NSString * msg))completion {
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"collegefold"] = productId;
    for (PersonalBlackModel *model in lapidantModel.black) {
        NSString *key = model.lotfication;
        NSString *type = model.admit;
        
        if ([type isEqualToString:@"binfightuous"]) {//enum
            NSString *value = model.tergmost;
            params[key] = value;
        } else if ([type isEqualToString:@"flaccling"] || [type isEqualToString:@"radioeer"]) {//txt || city
            NSString *value = model.propriics;
            params[key] = value;
        }
    }
    
    [UPNetworkManager.sharedManager POST:@"/openry/ap"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            completion(YES, response.enneasome);
        } else {
            completion(NO, response.enneasome);
        }
    }];
}

+ (void)fetchContactInfoWithProductId: (NSString *)productId
                           completion:(void(^)(ContactLapidantModel *lapidantModel, NSString * msg))completion {
    
    NSDictionary *params = @{
        @"collegefold": productId,
        @"blackitude": confusionString()
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/vorment"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            ContactLapidantModel *model = [ContactLapidantModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchSaveContactInfoWithProductId: (NSString *)productId
                            circumibility: (NSArray<ContactCircumibilityModel *> *)circumibility
                               completion:(void(^)(BOOL success, NSString * msg))completion {
    
    NSDictionary *params = @{
        @"collegefold": productId,
        @"lapidant": [self convertToCompactJSON:circumibility]
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/mantistic"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            ContactLapidantModel *model = [ContactLapidantModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

// 转换函数 - 生成紧凑JSON字符串
+ (NSString *)convertToCompactJSON:(NSArray<ContactCircumibilityModel *> *)contacts {
    // 转换为字典数组
    NSMutableArray *dictArray = [NSMutableArray arrayWithCapacity:contacts.count];
    
    for (ContactCircumibilityModel *contact in contacts) {
        [dictArray addObject:@{
            @"consumeratic": contact.consumeratic ?: @"",
            @"quindecimlocalety": contact.quindecimlocalety ?: @"",
            @"droplike": contact.droplike ?: @"",
            @"oramile": contact.oramile ?: @""
        }];
    }
    
    // 使用默认选项生成紧凑JSON
    NSError *error = nil;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictArray options:0 error:&error];
    
    if (error) {
        NSLog(@"JSON转换错误: %@", error);
        return @"";
    }
    
    return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}

+ (void)fetchBankInfoWithProductId: (NSString *)productId
                        completion:(void(^)(PersonalLapidantModel *lapidantModel, NSString * msg))completion {
    
    NSDictionary *params = @{
        @"collegefold": productId
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/whomatic"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            PersonalLapidantModel *model = [PersonalLapidantModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)fetchSaveBankInfoWithProductId: (NSString *)productId
                         lapidantModel: (PersonalLapidantModel *)lapidantModel
                            completion:(void(^)(BOOL successs, NSString * msg))completion {
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"collegefold"] = productId;
    for (PersonalBlackModel *model in lapidantModel.black) {
        NSString *key = model.lotfication;
        NSString *type = model.admit;
        
        if ([type isEqualToString:@"binfightuous"]) {//enum
            NSString *value = model.tergmost;
            params[key] = value;
        } else if ([type isEqualToString:@"flaccling"] || [type isEqualToString:@"radioeer"]) {//txt || city
            NSString *value = model.propriics;
            params[key] = value;
        }
    }
    
    [UPNetworkManager.sharedManager POST:@"/openry/circumibility"
                              domainType:UPDomainTypeDefault
                                  params:params
                             contentType:UPFieldHeaderContentTypeFormURLEncoded callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            completion(YES, response.enneasome);
        } else {
            completion(NO, response.enneasome);
        }
    }];
}

+ (void)reportLocationInfoWithLocationInfo: (UPLocationInfo)locationInfo
                                completion:(void(^)(BOOL success))completion {
    
    NSDictionary *parameters = @{
        @"ruriian": locationInfo.province ?: @"",
        @"habitation": locationInfo.countryCode ?: @"",
        @"rarible": locationInfo.country ?: @"",
        @"sonard": locationInfo.street ?: @"",
        @"saursome": @(locationInfo.latitude),
        @"specificization": @(locationInfo.longitude),
        @"create": locationInfo.city ?: @"",
        @"baseor": confusionString(),
        @"necessaryic": locationInfo.district ?: @""
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/tachyion"
                              domainType:UPDomainTypeDefault
                                  params:parameters
                             contentType:UPFieldHeaderContentTypeFormURLEncoded
                                callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            completion(YES);
        } else {
            completion(NO);
        }
    }];
}

+ (void)reportDeviceInfoWithCompletion:(void(^)(BOOL success))completion {
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    // nothlessDic
    NSDictionary *storageInfo = [UPDeviceInfo getStorage];
    NSNumber *freeStorage = storageInfo ? storageInfo[@"free"] : @(-1);
    NSNumber *totalStorage = storageInfo ? storageInfo[@"total"] : @(-1);
    
    NSDictionary *memoryInfo = [UPDeviceInfo getSystemMemory];
    NSNumber *totalMemory = memoryInfo[@"total"];
    NSNumber *freeMemory = memoryInfo[@"free"];
    
    NSDictionary *factyDic = @{
        @"vailably": freeStorage,
        @"felinoee": totalStorage,
        @"blenn": totalMemory,
        @"arriveia": freeMemory
    };
    dic[@"facty"] = factyDic;
    
    // leucDic
    NSDictionary *batteryInfo = [UPDeviceInfo getBatteryInfo];
    NSInteger batteryLevel = (NSInteger)([batteryInfo[@"level"] floatValue] * 100);
    NSString *isCharging = [batteryInfo[@"isCharging"] boolValue] ? @"1" : @"0";
    
    NSDictionary *notosureDic = @{
        @"teacherion": @(batteryLevel),
        @"foodar": confusionString(),
        @"pepsaster": isCharging
    };
    dic[@"notosure"] = notosureDic;
    
    // novelDic
    NSDictionary *deviceInfo = [UPDeviceInfo getDeviceInfo];
    NSString *deviceName = deviceInfo ? deviceInfo[@"name"] : @"";
    NSNumber *measure = deviceInfo ? deviceInfo[@"measure"] : @0;
    
    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
    CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
    
    NSDictionary *cosmoageDic = @{
        @"actdom": [UPDeviceInfo systemVersion],
        @"speak": @"iPhone",
        @"emal": [UPDeviceInfo modelCode],
        @"scoliling": deviceName,
        @"lepidoard": @(screenHeight),
        @"faciistic": @(screenWidth),
        @"pallitarium": measure
    };
    dic[@"cosmoage"] = cosmoageDic;
    dic[@"tenulet"] = confusionString();
    
    // mentcostastDic
    NSDictionary *aloneficationDic = @{
        @"rhodian": @100,
        @"troubleful": @"0",
        @"secutacle": @([UPDeviceInfo isSimulator]),
        @"mesive": @([UPDeviceInfo isJailbroken]),
        @"whenette": confusionString()
    };
    dic[@"alonefication"] = aloneficationDic;
    
    NSDictionary *pamition = @{
        @"eninterestitor": [UPDeviceInfo timezoneID],
        @"friendant": @([UPDeviceInfo isUsingProxy]),
        @"amphcy": @([UPDeviceInfo isUsingVPN]),
        @"mership": [UPDeviceInfo carrierName],
        @"aurule": getIDFVForKey(),
        @"teleoify": [UPDeviceInfo deviceLanguage],
        @"pickency": confusionString(),
        @"meetingful": confusionString(),
        @"authorityance": [UPDeviceInfo networkType],
        @"campaignsion": @([UPDeviceInfo isPhone]),
        @"tenta": [UPDeviceInfo ipAddress],
        @"larvfaction": [UPDeviceInfo macAddress],
        @"lieeur": [[UPIDFAManager shared] getIDFA]
    };
    dic[@"pamition"] = pamition;
    
    UPLocationManager *manager = [UPLocationManager sharedManager];
    [manager upGetCurrentWifiInfoWithCompletion:^(UPWifiInfo info) {
        NSDictionary *gerchildencyDic = @{
            @"rightitious": info.bssid ?: @"",
            @"vitu": info.ssid ?: @"",
            @"larvfaction": info.bssid  ?: @"",
            @"quindecimlocalety": info.ssid ?: @"",
            @"plectibility": confusionString()
        };
        
        NSMutableDictionary *gravpaintingDic = [NSMutableDictionary dictionary];
        gravpaintingDic[@"gerchildency"] = @[gerchildencyDic];
        dic[@"gravpainting"] = gravpaintingDic;
        
        // 转换为base64
        NSString *base64String = [dic dictionaryToBase64];
        
        NSDictionary *parameters = @{
            @"lapidant": base64String ?: @""
        };
        
        [UPNetworkManager.sharedManager POST:@"/openry/calidine"
                                  domainType:UPDomainTypeDefault
                                      params:parameters
                                 contentType:UPFieldHeaderContentTypeFormURLEncoded
                                    callback:^(UPResponse *response) {
            if (response.lotfication == 0) {
                completion(YES);
            } else {
                completion(NO);
            }
        }];
    }];
}

+ (void)reportToGoogleMarketWithCompletion:(void(^)(GoogleMarketModel *model, NSString * msg))completion {
    NSDictionary *parameters = @{
        @"aurule": getIDFVForKey(),
        @"spirsure": confusionString(),
        @"lieeur": [[UPIDFAManager shared] getIDFA]
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/falsitor"
                              domainType:UPDomainTypeDefault
                                  params:parameters
                             contentType:UPFieldHeaderContentTypeFormURLEncoded
                                callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            GoogleMarketModel *model = [GoogleMarketModel mj_objectWithKeyValues:response.lapidant];
            completion(model, response.enneasome);
        } else {
            completion(nil, response.enneasome);
        }
    }];
}

+ (void)reportToMaiDian:(UPSceneType)sceneType
              productId:(NSString *)productId
             productNum:(NSString *)productNum
         startTimeStamp:(NSInteger)startTimeStamp
           endTimeStamp:(NSInteger)endTimeStamp
             completion:(void(^)(BOOL success))completion {
    NSString *latitude = [NSString stringWithFormat:@"%f", [UPUserDefaults doubleForKey:latitudeKey]];
    NSString *longitude = [NSString stringWithFormat:@"%f", [UPUserDefaults doubleForKey:longitudeKey]];
    NSString *startTime = [NSString stringWithFormat:@"%ld", startTimeStamp];
    NSString *endTime = [NSString stringWithFormat:@"%ld", endTimeStamp];
    NSDictionary *parameters = @{
        @"heredhour": productId ?: @"",
        @"centen": sceneType ?: @"",
        @"viciacity": productNum ?: @"",
        @"pectorment": getIDFVForKey() ?: @"",
        @"therilike": [[UPIDFAManager shared] getIDFA] ?: @"",
        @"specificization": latitude,
        @"saursome": longitude,
        @"gam": startTime ?: @"",
        @"famparticularibility": endTime ?: @""
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/filmcy"
                              domainType:UPDomainTypeDefault
                                  params:parameters
                             contentType:UPFieldHeaderContentTypeFormURLEncoded
                                callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            completion(YES);
        } else {
            completion(NO);
        }
    }];
}

+ (void)reportContacts:(NSString *)contactsString
            completion:(void(^)(BOOL success))completion {

    NSDictionary *parameters = @{
        @"tergmost": @"3",
        @"pressureade": confusionString(),
        @"tetanie": confusionString(),
        @"lapidant": contactsString,
    };
    
    [UPNetworkManager.sharedManager POST:@"/openry/buyation"
                              domainType:UPDomainTypeDefault
                                  params:parameters
                             contentType:UPFieldHeaderContentTypeFormURLEncoded
                                callback:^(UPResponse *response) {
        if (response.lotfication == 0) {
            completion(YES);
        } else {
            completion(NO);
        }
    }];
}

@end
